
#include "utils.h"

typedef struct { uchar r, g, b; } rgb;

class edge
{
public:
	float w;
	int a, b;
};

class uni_elt
{
public:
	int rank;
	int p;
	int size;
};

class universe 
{
public:
  universe(int elements);
  ~universe();
  int find(int x);  
  void join(int x, int y);
  int size(int x) const { return elts[x].size; }
  int num_sets() const { return num; }

private:
  uni_elt *elts;
  int num;
};

class egl_segment
{
public:
	egl_segment();
	int process(Mat &src, Mat &dst);

private:
	float diff(Mat &img, int x1, int y1, int x2, int y2);
	universe* segment_graph(int num_vertices, int num_edges, edge *edges, float c);

	float sigma;
	float k;
	int min_size;

	int num_ccs;	//output
};